<script setup lang="ts">
import SList from '@/components/common/list/SList.vue'
import { invoiceListApi } from '@/api/invoice-api'
import type { ResultData } from '@/api/service'
import type { Page } from '@/type/common/list-types'
import type { InvoiceVo } from '@/type/Invoice'
import { useList } from '@/composables/list-composable'

const props = defineProps<{
  filters: any
}>()

const viewId = 'InvoiceList'
const { tableData, pageQuery, statement, total, tableLoading, search, hiddenColumn } = useList(
  viewId,
  getData,
  () => {
  }
)

function getData() {
  // 初始化外部传递的过滤参数
  pageQuery.filters = props.filters
  pageQuery.sortRules = [{field: "tranDatetime", direction: "ascending"}]
  statement.value.mateForm = []
  statement.value.mateList.find((it: any) => it.property === 'tranDatetime').sortable = null
  hiddenColumn('tranType')
  hiddenColumn('tranStatus')
  hiddenColumn('paymentType')
  hiddenColumn('tranErType')
  tableLoading.value = true
  invoiceListApi(pageQuery).then((response: ResultData<Page<InvoiceVo[]>>) => {
    total.value = response.data.total
    tableData.value = response.data.modelList
    tableLoading.value = false
  })
}

const methods = {}
</script>

<template>
  <s-list
    :statement="statement"
    :data="tableData"
    :methods="methods"
    :total="total"
    :table-loading="tableLoading"
    :page-size="pageQuery.pageSize"
    :top-button-show="false"
    @search="search"
  >
  </s-list>
</template>

<style scoped></style>
